<template>
  <div class="NewPeople">
    <div class="new-ipt">
      <el-input
        v-model="inputName"
        class="newPeople-ipt"
        placeholder="新人姓名"
      ></el-input>
      <el-input
        v-model="inputPhone"
        class="newPeople-ipt"
        placeholder="新人手机号"
      ></el-input>
      <el-button type="primary" class="newPeople-search">搜索</el-button>
    </div>

    <el-table :data="tableData" style="width: 100%" max-height="250">
      <el-table-column prop="num" label="编号" width="80"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="80"> </el-table-column>
      <el-table-column prop="telephone" label="手机号" width="120">
      </el-table-column>
      <el-table-column prop="email" label="邮箱" width="180"> </el-table-column>
      <el-table-column prop="time" label="注册时间" width="200">
      </el-table-column>
      <el-table-column prop="accountBalance" label="账号状态" width="80">
      </el-table-column>
      <!-- <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="deleteRow(scope.$index, tableData)"
            type="text"
            size="small"
          >
            账号禁用
          </el-button>
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>

<script>
import api from "../../../api";

export default {
  name: "NewPeople",
  // methods:{
  //   deleteRow(index,rows){
  //     rows.splice(index,1)
  //   }
  // },
  data() {
    return {
      inputName: "",
      inputPhone: "",
      tableData: [],
    };
  },
  mounted() {
    api.getSearchNewPeople({ search: "" }).then((res) => {
      console.log(res.data);
      for (let i = 0; i < res.data.length; i++) {
        // var date = new(Date);
        // date.toLocaleDateString
        res.data[i].regdate = new(Date);
        var time = res.data[i].regdate.toLocaleDateString()
        // console.log(res.data[i].regdate.toLocaleDateString());
        this.tableData.push({
          num: res.data[i].pid,
          name: res.data[i].pname,
          telephone: res.data[i].pphone,
          email: res.data[i].pmail,
          time: time,
          accountBalance: res.data[i].status,
        });
      }
    });
  },
};
</script>

<style scoped>
.new-ipt {
  width: 1000px;
  padding: 20px;
}
.newPeople-ipt {
  float: left;
  width: 190px;
  margin-left: 20px;
}
</style>